<script>
$("document").ready(function(){
	//alert('qqq');
	$("th span").click(function(){


		var a_all=$("form").serialize();

		//alert($(this).attr("id") );


		$("#page").val( $(this).attr("class") );

		


		$.post(	"/pair/ajax_pair_result", 
				$("form").serialize(),
				function(data){
					console.log(data);
					$("#cc").html('');
					$("#cc").html(data);
				});


		

		//return false;
	});
});
</script>


<table id="tablesorter-demo" class="table" border="0" cellpadding="0" cellspacing="1">
	<thead>
		<tr class="success">
			
			
			
			
			<th style=" cursor: ; ">
							<?php							
							 
							if($page>=1 AND $page!=0){
							?>
								<span style="color:blue;cursor: pointer;"  class="<?=($page-1)?>"> 
									上一頁
								</span>
							<?php
							}
							?>
				建物面積
			</th>
			<th style="   ">土地面積</th>
			<th style="   ">總價</th>
			
			<th style="  width: 75px; ">地址</th>
			<th style="  width: 75px; ">屋齡</th>
			<th style="  width: 75px; ">物件用途</th>
			
			<th style="    width: 75px; ">經紀人</th>
			<th style="    width: 75px; ">建檔日期</th>
			
			
			
			
			<th style="     width: 75px; ">市調/需求編號</th>

			<th style=" width: 50px; ">
				操作
				<?php							
							if($result->num_rows==10 AND $result->num_rows >= 1){
							
								echo '<span class="'.($page+1).'" style="color:blue;cursor: pointer;" >';
								echo ' 下一頁 ';
								echo '</span>';							
							}
							?>
			</th>
		</tr>
	</thead>
	<tbody >
		<?php

$back_count=1;
$demand_ids = array();
foreach($result->result() as $val){
	$demand_ids[]=$val->demand_id;
		
		?>
		<tr <?=($back_count % 2 == 0) ? 'class="warning"' : '' ?>>

			

			<td >
			<?php
				//echo '建物面積：';
				echo $val -> building_area1;
				echo '~';
				echo $val -> building_area2;
				
				?>
			</td>
			
			<td >
			<?php
				
				//echo '土地面積：';
				echo $val -> land_area1;
				echo '~';
				echo $val -> land_area2;
				?>
			</td>
			
			
			<!--
			<td style="">
			<!--區域路段-
			<?php
echo '重點區域：';
echo $val -> key_areas1 ? $val -> key_areas1 : '';
echo $val -> key_areas2 ? $val -> key_areas2 : '';
echo '<br>';
echo '建物門牌：';
echo ($val -> sections1) ? $val -> sections1 : '';
echo ($val -> sections2) ? $val -> sections2 : '';
			?>
			</td>

			<td>
			<!--面積坪數--
				<?php
				echo '建物面積：';
				echo $val -> building_area1;
				echo '~';
				echo $val -> building_area2;
				echo '<br>';
				echo '土地面積：';
				echo $val -> land_area1;
				echo '~';
				echo $val -> land_area2;
				?>
			</td>
		-->
			
			<td>
			<!--價格-->
			<?php
			//echo '總預算：';
			echo $val -> total_budget1;
			echo '~';
			echo $val -> total_budget2;
			
			?>
			</td>
			
			
			<td style="">
			<!--區域路段-->
			<?php

			
			echo ($val -> sections1) ? $val -> sections1 : '';
			//echo '<br>';
			//echo ($val -> sections2) ? $val -> sections2 : '';
			?>
			</td>
			
			
			<td>
			<!--屋況樓層-->
			<?php
			echo   $val -> year_of_construction;
			
			?>

			</td>
			
			<td>
			<?php
			if (isset($object_usages[$val -> object_usage]))
				echo $object_usages[$val -> object_usage];
			//echo $val -> object_usage;
			?>
			<!--需求狀態-->
			</td>
			

			<td>
			<!--買方經紀人-->
			<?php
			if (isset($users[$val -> broker])) {
				echo $users[$val -> broker];
			}
			?>
			</td>
			
			<td>			
			<?php
				echo date('Y-m-d',$val -> broker);			
			?>
			</td>
			
			<td>
			<?php
			$t_str = "";

			if ($val -> type_rent == "1") {
				$t_str = "租賃";
			}
			if ($val -> type_sell == "1") {
				$t_str = "買賣";
			}
						
			//echo $t_str;
			
			echo $val -> demand_serial;
			
			
			?></td>
			
			
			<!--
			<td >
			<?php
			echo '案名：';
			echo $val -> object_name1;
			echo $val -> object_name2;
			echo '<br>';
			echo '大樓名稱：' . $val -> building_name;
			?>
			<!--需求標題--
			</td>
			-->

			<td >				
				
				<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg<?= $val -> demand_id?>">
					物件查看
				</button>
				
				<a href="#" id="disable_demand" class="<?= $val -> demand_id ?>" >
						<img src="/images/disable.png"  border="0" />
				</a>	
						
				
				
			</td>
		</tr>
		<?
		$back_count++;
		}

$demand_id_flag=true;
$demand_id_str='';
foreach ($demand_ids as $key => $value) {
	if($demand_id_flag){
		$demand_id_flag=false;
		$demand_id_str.=$value;
	}else{
		$demand_id_str.=','.$value;
	}
	
	
}


		?>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="15">
			<div style="float:right">

				<?php
				//if (is_object($resu) AND !empty($resu))
				//echo $victor_page;
				?>

			</div></td>
		</tr>
	</tfoot>
</table>

<input type="hidden" id="ymdhis_mh5" value="<?=md5(date("ymdhis") )?>" />
<input type="hidden" id="demand_many" value="<?=$demand_id_str?>" />
<?php

//foreach ($show_box_infos as $key => $value) {
//	echo $value;
	
//}
?>



